<template>
  <section class="gallery-container" @click="handleGallaryClick">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <swiper-slide v-for="(item, index) in imgList" :key="index">
          <img class="gallery-img" :src="item">
        </swiper-slide>
        <span class="swiper-pagination" slot="pagination"></span>
      </swiper>
    </div>
  </section>
</template>
<script>
export default {
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: true,
        observer: true
      }
    }
  },
  props: {
    imgList: {
      type: Array,
      default () {
        return []
      }
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('close')
    }
  }
}
</script>
<style lang="stylus" scoped>
.gallery-container >>> .swiper-container
  overflow inherit
.gallery-container
  position fixed
  left 0
  right 0
  top 0
  bottom 0
  background-color #000
  display flex
  flex-direction column
  justify-content center
  z-index 99
  .wrapper
    height 0
    width 100%
    padding-bottom 100%
    .gallery-img
      width 100%
    .swiper-pagination
      color #fff
      bottom -1rem
</style>
